package com.hotel.front;

import java.io.IOException;
import java.text.ParseException;
import java.util.List;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.appengine.labs.repackaged.org.json.JSONException;
import com.google.gson.Gson;
import com.hotel.BL.HoardingLogic;

import data.HoardingData;

@SuppressWarnings("serial")
public class HoardingService extends HttpServlet {
		
	//http://localhost:8080/HoardingService?func=QueryHoarding
	
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws IOException {
			String func = req.getParameter("func");
		
		try{
			
			if(func.equals("QueryHoarding"))
				QueryHoarding(req,resp);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
		
	
	private void QueryHoarding(HttpServletRequest req, HttpServletResponse resp) throws IOException, JSONException, ParseException
	{		
		List<HoardingData> obj = new HoardingLogic().QueryHoarding();
		
		Gson gson = new Gson();
			resp.setContentType("text/plain; charset=UTF-8");
		resp.getWriter().println(gson.toJson(obj));
	}
}
